<?php
/**
 * @file
 * JavaScript for GreenInDeed.
 *
 * Usage:
 *  - A page that wants to use this JavaScript file should link to this file
 *    using the '<script></script>' tags once and only once.
 *
 * Parameter(s):
 *  - None.
 *
 * Global variable(s) set:
 *  - None.
 *
 * Global variable(s) unset:
 *  - None.
 *
 * Exception(s):
 *  - None.
 *
 * This file includes/requires:
 *  - h_greenindeed.php
 *  - h_home.php
 *  - h_jqui.php
 */

// header file(s) ==============================================================
require_once "h_greenindeed.php";
require_once "h_home.php";
require_once $PATH_COMMON . "php/h_jqui.php";


// implementation ==============================================================
?>
// <script> // to induce syntax highlighting on netbeans

// implementation --------------------------------------------------------------
// jquery initialization
$(document).ready(init);

/**
 * Initialization.
 *
 * Because of synchronization problems, we cannot split initialization of the
 * individual modules into multiple jQuery initialization blocks called from
 * within each module's own JavaScript files. E.g. Filter must be initialized
 * before loading deeds but there is no simple way to achieve that.
 */
function init() {

  // hover event binding for image buttons (jquery)
  $(".<?php echo JQUI_CSS_CLASS_BUTTON ?>").hover(
    function () { $(this).addClass("ui-state-hover") },
    function () { $(this).removeClass("ui-state-hover") }
  );

  // accordian (jquery)
  // Note: Cannot use jQuery UI's accordian because that allows only one
  //       section to be open at any time.
  $(".<?php echo CSS_CLASS_ACCORDION ?>").click(function () {
    $(this).next().toggle();
    return false;
  }).next().show(1);

  // initialize other modules
  header_init();
  filter_init(deed_view);
  deed_init();

  // load view deed page
  deed_view();
}

// </script> // to induce syntax highlighting on netbeans
